package com.eke.dao;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.eke.bean.ClassHour;
import com.eke.bean.CourseChapters;
import com.jason.dbhelper2.jdbc.BaseJdbcTemplate;

@Repository("courseChaptersDao")
public class CourseChaptersDao extends BaseJdbcTemplate<CourseChapters>{
	/**
	 * 添加课程返回章节ID
	 * @param courseChapters
	 * @return	courseChaptersId
	 */
	public int addCourseChapter(CourseChapters courseChapters) {
		// TODO Auto-generated method stub
		String idSql = "SELECT @@Identity";
		this.insert(courseChapters);
		Map<String, Object> map = this.getJdbcTemplate().queryForMap(idSql);
		return ((BigInteger) map.get("@@Identity")).intValue();

	}
	/**
	 * 查询章节
	 * @param courseId 课程id
	 * @return List<CourseChapters>
	 */
	public List<CourseChapters> queryCourseChapter(Integer courseId){
		String sql="select * from course_chapters where course_id=?";
		return this.queryForList(sql, courseId);
	}
}
